<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Blog;
use Illuminate\Support\Facades\Auth;

class BlogsController extends Controller
{
    public function store(Request $request)
    {
        $this->validate($request,[
            'content' => 'required',
        ]);
        Blog::create([
            'user_id' => Auth::user()->id,
            'content' => $request->input('content')
        ]);
        session()->flash('success','发布成功鸭！');
        return back();
    }

    public function destroy(Blog $blog)
    {
        //$this->authorize('destroy',$blog);
        $blog->delete();
        session()->flash('success','删除成功鸭！');
        return back();
    }
}
